<script type="text/javascript">
	$(document).ready(function() {
		$("#reciever").tablesorter({
			widthFixed: true,
			widgets: ['zebra']
		}).tablesorterPager({
			container: $(".pager")
		});
	});

	function confirmation() {
		var n = noty({
			text: "Status akan diaplikasikan pada semua mahasiswa penerima beaasiswa ini. Lanjutkan?",
			type: "warning",
			dismissQueue: true,
			layout: "center",
			theme: "default",
			buttons: [
				{addClass: 'btn btn-primary', text: 'Ok', onClick: function($noty) {
			        $noty.close();
					$("#changestatus").submit();}
				},
			    {addClass: 'btn btn-danger', text: 'Cancel', onClick: function($noty) {
			    	$noty.close(); }
			    }
			]
		});
		return false;
	}
</script>

<div id="main-content" class="prepend-1 span-19 last">
<?php 
	if (isset($changestatus)) {
		if ($changestatus == 'failed') {
			echo '<span class="error">Status gagal diubah. Silakan coba beberapa saat lagi.</span><br /><br />';
		} else if ($changestatus == 'success') {
			echo '<span class="info">Status berhasil diubah.</span><br /><br />';
		}
	}
?>
<h3>Detil Beasiswa - <?php echo $scholarship->name; ?></h3>
	<table>
		<tr>
			<td width="200"><label>Nama Beasiswa</label></td>
			<td><?php echo $scholarship->name; ?></td>
		</tr>
		<tr>
			<td><label>Awal Periode</label></td>
			<td><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_start)); ?></td>
		</tr>
		<tr>
			<td><label>Akhir Periode</label></td>
			<td><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_end)); ?></td>
		</tr>
		<tr>
			<td><label>Batas Pendaftaran</label></td>
			<td><?php echo date(DAY_FORMAT, strtotime($scholarship->deadline)); ?></td>
		</tr>
		<tr>
			<td><label>Jenis Beasiswa</label></td>
			<td><?php echo $scholarship->type.nbs(3); ?></td>
		</tr>
		<tr>
			<td><label>Sponsor</label></td>
			<td><?php echo $scholarship->sponsor; ?></td>
		</tr>
		<tr>
			<td><label>Berkas Dibutuhkan</label></td>
			<td><?php echo $scholarship->required_files; ?></td>
		</tr>
		<tr>
			<td><label>Keterangan</label></td>
			<td><?php echo $scholarship->details; ?></td>
		</tr>
		<tr>
			<td><label>Status</label></td>
			<td><span class="info"><?php echo $status; ?></span></td>
		</tr>
		<tr>
			<td><label>Status Pengiriman</label></td>
			<td><span class="info"><?php echo $deliverystatus; ?></span></td>
		</tr>
		<tr>
			<td><b>Jumlah Penerima</b></td>
			<td><?php echo $counter; ?></td>
		</tr>
	</table>
	<div class="clear"><?php echo nbs(); ?></div>
	<h4>Form Ubah Status Pengiriman Beasiswa</h4>
	<p>Mohon diperhatikan status ini akan diaplikasikan ke semua mahasiswa yang menerima beasiswa ini.</p><br />
<?php
	if ($recievers == NULL) {
		echo '<span class="info">Tidak dapat ubah status. Tidak ada mahasiswa penerima beasiswa.</span><br />';
	}
	echo form_open($role.'/scholar/active/changedelivery', array('id' => 'changestatus', 'class' => 'form')); ?>
	<input type="hidden" name="id" value="<?php echo $scholarship->id; ?>" />
	<select name="delivery" <?php if ($recievers == NULL) echo ' disabled="disabled" '; ?>>
		<option value="belum dikirim" <?php if ($deliverystatus == 'belum dikirim') echo ' selected="selected" '; ?>>belum dikirim</option>
		<option value="sudah dikirim" <?php if ($deliverystatus == 'sudah dikirim') echo ' selected="selected" '; ?>>sudah dikirim</option>
	</select>
	<input onclick="confirmation();" type="button" class="submit" name="change" value="Ubah Status" <?php if ($recievers == NULL) echo ' disabled="disabled" '; ?> />
<?php 
	echo form_close(); ?>
	<div class="clear"><?php echo nbs(); ?></div>
	<h4><?php echo $title; ?></h4>
	<table id="reciever">
	<thead>
		<tr>
			<th>Nama Mahasiswa</th>
			<th width="150">Angkatan</th>
			<th width="300">Program Studi</th>
			<th width="150"><?php echo $studentstatus; ?></th>
		</tr>
	</thead>
	<tfoot>
		<?php echo $pager; ?>
	</tfoot>
	<tbody>
<?php 
	if ($recievers == NULL) :
?>
		<tr>
			<td align="center" colspan="4">
				<span class="info"><?php echo $empty; ?></span>
			</td>
		</tr>
<?php 
	else :
		foreach ($recievers as $reciever) :
?>
		<tr>
			<td><?php echo anchor($role.'/student/profile/index?id='.$reciever->id, $reciever->name, array('target' => '_blank')); ?></td>
			<td align="center"><?php echo $reciever->year; ?></td>
			<td><?php echo $reciever->major; ?></td>
			<td align="center"><?php echo $reciever->delivery; ?></td>
		</tr>
<?php 
		endforeach;
	endif;
?>
	</tbody>
	</table>
	<div class="clear"><?php echo nbs(); ?></div>
</div>